<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>
    <script type="text/javascript">
        window.onload=function (){
            document.getElementById("btn").onclick=function (){
                var username=document.getElementById("username").value;
                if (username.trim()==""){
                    console.log("提交失败!")
                }else{
                    console.log("恭喜"+username+"注册成功!");
                }
            }
            document.getElementById("username").onblur=function (){
                var username=document.getElementById("username").value;
                if (username.trim()==""){
                    console.log("用户名不能为空!")
                }
            }
        }
    </script>
</head>
<body>
<h1 align="center">用户注册</h1>
<!--./register.do-->
<form action="" method="post" style="width:300px;margin:0 auto;">
    用户名：<input type="text" name="username"  id="username" /><br>
    密码：<input type="password" name="password"  value="" /><br>
    性别：<input type="radio" name="sex"  checked="checked" />男
    <input type="radio" name="sex"  />女<br>
    电子邮箱：<input type="email" name="email"  /><br>
    电话号码：<input type="number" name="number" /><br>
    <button id="btn">提交</button>
</form>
</body>
</html>